package com.chis.jmdatatimer.comm;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Description 线程池单例
 * @Company zwx
 * @author jw
 * @date 2016年5月9日
 */
public class ThreadPoolSingle {

	/** 单例 */
	private static ThreadPoolSingle _singleton;
	/** 线程池 */
	private ExecutorService pool;

	// public AppThreadPoolFactoryMBean pool;

	/**
	 * 构造方法
	 */
	private ThreadPoolSingle() {
	}

	/**
	 * 初始化
	 * @return 单例
	 */
	public static synchronized final ThreadPoolSingle getInstance() {
		if (_singleton == null) {
			_singleton = new ThreadPoolSingle();
			_singleton.initialize();
		}
		return _singleton;
	}

	/**
	 * 初始化
	 */
	public void initialize() {
		pool = Executors.newFixedThreadPool(500);
		// pool = ThreadPoolConsumer.getInstance().getPoolFactory();
	}

	public ExecutorService getPool() {
		return pool;
	}

	public void setPool(ExecutorService pool) {
		this.pool = pool;
	}
}
